<template>
	<view class="index">
		<nav-bars backState="1000"  bgColor="#fff" fontColor="#000" title="分销学堂"></nav-bars>
		<view class="articelist">
			<scroll-view class="s_dList" scroll-y @scrolltolower="scrolldata">
				<view class="list" v-for="(items,indexs) in list" :key="indexs">
					<view class="i_cont" @click="gitdetail(items.id)">
						<view class="i_img"><image :src="items.cover"></image></view>
						<view class="i_bOper">
							<view class="i_tit">{{items.title}}</view>
							<view class="i_tits">{{items.brief}}</view>
							<view class="i_time">{{items.ctime}} <text>阅读:{{items.pv}}</text></view>
						</view>
					</view>
				</view>
		   </scroll-view>
		</view>

	</view>
</template>

<script>
import navBar from "@/components/navBar/navBar.vue"
import service_now from '@/service/now.js'
import service_mall from '@/service/mall.js'
import URL from '@/config/url.js'


export default {
	components: { navBar },
	
	data() {
		return {
		  page:1,
		  list:[],
		}
	},
	onLoad(params) {
		this.$utils.getUrl()
		this.id =params.id
		this.getlist()
		this.userId = uni.getStorageSync('userId')
		let token = uni.getStorageSync('token')
		if(params.share_uid){
			let shareuId= params.share_uid
			this.$store.commit('index/SET_shareuId', shareuId)
			if(token && shareuId){
				service_mall.getPromoter({share_uid:shareuId})
					.then(res => {
				})
			}
		}
	},
	onShareAppMessage(res) {
		let that = this
		if (res.from === 'button') {}
		return {
		  title: '创客学堂',
		  path: '/pages/now/creator/index?share_uid='+ this.userId,
		  success: function (res) {
		  }
		}  
	},
	methods: {
		// 获取list
		getlist() {
			let params = {
				page:this.page,
				pagesize:15,
			}
			service_now.getpaging(params)
			.then(res => {
				if (res.code == 1) {
					let data = res.data.articles
					for(var i=0;i<data.length;i++){
						this.list.push(data[i]); // 加载的数据追加在上一页后面
					}
				}
			})
		},
		tabs(id){
			this.page =1
			this.list= []
			this.getlist()
		},
		scrolldata(){
			this.page++,
			this.getlist()
		},
		gitdetail(id){
			uni.navigateTo({
				url:'/pages_now/pages/now/creator/detail?id=' + id
			})
		}
	
	}
}
</script>

<style lang="scss" scoped>
.index{
	width: 100vw;height: 100vh;background: #fff;display: flex;flex-flow: column;overflow:hidden;
}
.articelist{
	height:calc(100% - 136rpx);
}
.tabtop{
	line-height: 90rpx;
	font-size: 32rpx;
	padding:0 30rpx;
	font-weight: bold;
	.i_more{
		font-size: 28rpx;
		 font-weight: normal;
		float: right;
		color: #999;
	}
}
.list{
	padding:0 30rpx;
}
.s_dList {width: 100%;height:calc(100% - 80rpx);flex: 1;}
.i_cont{
	height: 240rpx;
	padding: 20rpx;
	padding-right:0;
	padding-left: 220rpx;
	position: relative;
	.i_img{
		position: absolute;
		width: 200rpx;
		height: 200rpx;
		top:20rpx;
		left: 0;
		border-radius: 10rpx;
		overflow: hidden;
	}
	.i_tit{
		font-size:30rpx;
		height: 80rpx;
		overflow: hidden;
		 text-overflow: ellipsis;
		 display: -webkit-box;
		 -webkit-line-clamp: 2;
		 -webkit-box-orient: vertical;
		 margin-bottom: 10rpx;
	}
	.i_tits{
		font-size:26rpx;
		height: 68rpx;
		overflow: hidden;
		 text-overflow: ellipsis;
		 display: -webkit-box;
		 -webkit-line-clamp: 2;
		 -webkit-box-orient: vertical;
		 margin-bottom: 10rpx;
		  color: #999;
	}
	.i_time{
		font-size:26rpx;
		color: #999;
		text{
			float: right;
		}
	}
}
.select_box{
  float: right;	
  font-weight: normal;
}
.select_box text {
	width: 140rpx;
	float: left;
	display: block;
	text-align: center;
	color: #666;
	font-size: 30rpx;
}
.select_box .on {
    border-bottom: 2px solid #d61518;
    color: #333;
}
.option_box{
	margin: 20rpx auto;
	padding-top: 10rpx;
	overflow:hidden;
}
.option_list{
	float: left;
	width: 25%;
	text-align: center;
	margin-bottom: 10rpx;
}
.option_list image{
	display: block;
	margin: 10rpx auto;
	width: 70rpx;
	height: 70rpx;
}
.tabs{
	white-space: nowrap;
	line-height:80rpx;
	min-width: 100%;
	margin-left:30rpx;
	overflow-x:auto;
	.tab{
		padding-right:30rpx;
	}
	.active{
		font-weight:bold;
		font-size:32rpx;
	}
}
</style>